/**!
 * 问题库类别
 * author: wangkai;
 */

$(function() {
    var $categorylist = $("#categorylist");
    var categorylistTmpl = Util.clearHtml($("#categorylist-tmpl").html());
    var M = Mustache;
    M.parse(categorylistTmpl);
    $.ajaxSettings.async = false; //同步加载
    $.ajax({
        url: Util.AjaxRUrl+'replyDepart',
        type: "post",
        async: false,
        dataType: "json",
        data: {
            param: '{}'
        },
        success: function(data) {
            if (data.replyDepart) {
                $.ajaxSettings.async = true; //异步加载
                renderList(data.replyDepart);
            }
        },
        error: function(XMLHttpRequest, txtStatus, errorThrown) {
            console.log(XMLHttpRequest);
        }
    });

    function renderList(data) {
        $categorylist.html(M.render(categorylistTmpl, { items: data }));
        var pdeptguid = Util.getUrlParams("departGuid");
        if (pdeptguid == undefined || pdeptguid == "") {
            //$(".ewb-category-node").eq(0).addClass('current');
        } else {
            $(".ewb-category-node[data-role=" + pdeptguid + "]").addClass('current');
        }
        //$("#categorylist").find('li').eq(0).addClass('current'); //模拟选中的是第一个
        /* $('.ewb-category li a').each(function(){  
        if($($(this))[0].href==String(window.location))  
            $(this).parent().addClass('current');  
        });  */
    }

});
